from django.http import HttpResponse
from django.shortcuts import render

from One2One.models import User, IDCard


# Create One2One views here.


# 查询操作
def get_user_or_idcard(request):

    # 查找某用户的身份证信息
    user = User.objects.get(id=1)
    print(user.idcard.idcard_num, user.idcard.address)

    # 查找身份证对应的用户
    id_card = IDCard.objects.get(id=1)
    print(id_card.user.name, id_card.user.age, id_card.user.gender)   # 这里不要写 _set

    return HttpResponse('查询成功！')
